<template>
 <div>
<el-dialog
  title="题目审核"
  :visible.sync="dialogVisible"
  width="30%"
>
  <el-form ref="form" :model="form" label-width="80px" :rules="rules">
  <el-form-item>
    <el-radio-group v-model="form.chkState">
      <el-radio label="通过"></el-radio>
      <el-radio label="拒绝"></el-radio>
    </el-radio-group>
  </el-form-item>
    <el-form-item>
<el-input type="textarea" v-model="form.chkRemarks" placeholder="请输入审核意见"></el-input>
  </el-form-item>
</el-form>
  <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="changeAudit">确 定</el-button>
  </span>
</el-dialog>
 </div>
</template>

<script>
export default {
  name: 'audit',
  props: {
    id: {
      type: Number,
      default: null
    }
  },
  data () {
    return {
      dialogVisible: false,
      form: {
        id: null,
        chkState: 2,
        chkRemarks: ''
      },
      rules: {
        chkState: [{ required: true, message: '请选择', trigger: 'blur' }],
        chkRemarks: [{ required: true, message: '请输入', trigger: 'blur' }]
      }
    }
  },
  methods: {
    openDialog () {
      this.dialogVisible = true
    },
    closeDialog () {
      this.form = {
        id: null,
        chkState: 2,
        chkRemarks: ''
      }
      this.$refs.form.resetFields()
      this.dialogVisible = false
    },
    async changeAudit () {
      try {
        await this.$refs.form.validate()
        this.form.id = this.id
        this.$emit('changeQuestion', this.form)
        this.closeDialog()
      } catch (error) {
        console.log(error)
      }
    }
  }
}
</script>

<style scoped lang='less'>

</style>
